with Ada.Finalization;
with Ada.Strings, Ada.Strings.Hash, Ada.Strings.Unbounded; 
with Ada.Containers; 
with String_Lists, String_Hash_Maps, String_Hash_Sets;
use Ada.Strings, Ada.Strings.Unbounded;
use Ada.Containers;
package Conf4A is

   App_Config : constant String := "";

   type Setting_Type is tagged limited private;

   procedure Clear (this : in out Setting_Type);

   procedure Attach (
      This     : in out Setting_Type;
      Filename : String := App_Config
      ); 

   procedure Load (This : in out Setting_Type);

   procedure Save (This : in out Setting_Type);

   procedure Set (
      This  : in out Setting_Type;
      Key   : String;
      Value : String;
      Save_After_Changed : Boolean := False
      );

   function Get (
      This          : in Setting_Type;
      Key           : String;
      Default_Value : String := ""
      ) return String;

   procedure Delete (
      this : in out Setting_Type;
      Key : String;
      Save_After_Changed : Boolean := False
      );

   procedure Delete_Section (
      this : in out Setting_Type;
      Prefix : String;
      Save_After_Changed : Boolean := False
      );

   function Get (
      This          : in Setting_Type;
      Key           : String;
      Default_Value : Integer := 0
      ) return Integer;

   function Get (
      this          : in Setting_Type;
      Key           : String;
      Default_Value : Duration := 0.0
      ) return Duration;

   function Get (
      this          : in Setting_Type;
      Key           : String;
      Default_Value : Boolean := False
      ) return Boolean;

   procedure Read (
      This  : in Setting_Type;
      Key   : String;
      Value : in out Integer
      );

   procedure Read (
      This  : in Setting_Type;
      Key   : String;
      Value : in out Duration 
      );

    procedure Read (
      This  : in Setting_Type;
      Key   : String;
      Value : in out Boolean 
      );

    procedure Read (
       this : in Setting_Type;
       Key  : String;
       Value : in out Unbounded.Unbounded_String
       );

   procedure Iterate (
      This    : in out Setting_Type;
      Process : not null access procedure (Key, Value : String)
      );

   generic
      type Value_Type is (<>);
   function Generic_Get (
      This          : in Setting_Type;
      Key           : String;
      Default_Value : Value_Type := Value_Type'First
      ) return Value_Type;

private

   type Setting_Type is 
  -- new Ada.Finalization.Limited_Controlled with 
   tagged limited record
      Filename : Unbounded_String;
      Content  : String_Lists.List;
      Items    : String_Hash_Maps.Map;
   end record;

end Conf4A;

